#include "wx/wxprec.h"
#include "wx/xrc/xh_scrol.h"

IMPLEMENT_DYNAMIC_CLASS( wxScrollBarXmlHandler, wxXmlResourceHandler )

wxScrollBarXmlHandler::wxScrollBarXmlHandler()
  : wxXmlResourceHandler() {
  XRC_ADD_STYLE( wxSB_HORIZONTAL );
  XRC_ADD_STYLE( wxSB_VERTICAL );
  AddWindowStyles();
}

wxObject *wxScrollBarXmlHandler::DoCreateResource() {
  XRC_MAKE_INSTANCE( control, wxScrollBar )
  control->Create( m_parentAsWindow,
                   GetID(),
                   GetPosition(), GetSize(),
                   GetStyle(),
                   wxDefaultValidator,
                   GetName() );
  control->SetScrollbar( GetLong( wxT( "value" ), 0 ),
                         GetLong( wxT( "thumbsize" ), 1 ),
                         GetLong( wxT( "range" ), 10 ),
                         GetLong( wxT( "pagesize" ), 1 ) );
  SetupWindow( control );
  CreateChildren( control );
  return control;
}

bool wxScrollBarXmlHandler::CanHandle( wxXmlNode *node ) {
  return IsOfClass( node, wxT( "wxScrollBar" ) );
}
